﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1.segments.data_type
{
    class TS
    {
        public StringBuilder Time_Of_An_Event { get; set; }
        public StringBuilder Degree_Of_Precision { get; set; }

        public int fill(string source, int temp)
        {
            int i, x = 0;
            for (i = temp; i < source.Length; i++)
            {
                if (source[i] == '^')
                    x++;
                else if (source[i] == '|')
                {
                    Time_Of_An_Event.Capacity = Time_Of_An_Event.Length;
                    Degree_Of_Precision.Capacity = Degree_Of_Precision.Length;                    
                    return i;
                }

                else if (x == 0)
                {
                    if (Time_Of_An_Event == null)
                        Time_Of_An_Event = new StringBuilder();
                    Time_Of_An_Event.Insert(Time_Of_An_Event.Length, source[i]);
                }
                else if (x == 1)
                {
                    if (Degree_Of_Precision == null)
                        Degree_Of_Precision = new StringBuilder();
                    Degree_Of_Precision.Insert(Degree_Of_Precision.Length, source[i]);
                }             
            }
            return i;
        }

        public override string ToString()
        {
            string ts_string = "";

            if (Time_Of_An_Event != null)
                ts_string += Time_Of_An_Event;
            if (Degree_Of_Precision != null)
                ts_string += "^" + Degree_Of_Precision;

            return ts_string;
        }
    }
}
